package com.jdd.fintech.morse.plugin.enums;

/**
 * @description: 业务错误编码枚举
 * @date: 2021/12/24 11:38
 * @author: fengcheng
 **/
public enum BizErrorCodeEnum {
    SUCCESS("00000", "成功"),
    FAILURE_0("10000", "定制化版本不允许为空"),
    FAILURE_1("10001", "不支持此定制化版本"),
    FAILURE_2("10002", "未配置插件值，操作失败"),
    FAILURE_3("10003", "Morse请求对象加密失败"),
    FAILURE_4("10004", "Morse请求对象解密失败"),
    FAILURE_5("10005", "解密验签失败"),
    FAILURE_6("10006", "加密加签失败"),
    FAILURE_7("10007", "获取远程访问令牌失败"),
    FAILURE_8("10008", "RSAUtil.wyaksRsaEncrypt.网银AKS.RSA加密公共方法执行异常"),
    FAILURE_9("10009", "RSAUtil.wyaksRsaEncrypt.网银AKS.RSA解密公共方法执行异常"),

    ;
    /**
     * 业务错误编码Code
     */
    private String code;
    /**
     * 业务错误编码描述
     */
    private String desc;

    BizErrorCodeEnum(String code, String desc) {}

    public String getCode() {
        return this.code;
    }

    private void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return this.desc;
    }

    private void setDesc(String desc) {
        this.desc = desc;
    }

    @Override
    public String toString() {
        return "BizErrorCodeEnum." + this.name() + "{code=" + this.getCode() + ", desc=" + this.getDesc() + "}";
    }

    /**
     * 按code反查枚举项
     * @param code
     * @return
     */
    public static BizErrorCodeEnum getEnumByCode(String code){
        for (BizErrorCodeEnum bizErrorCodeEnum : BizErrorCodeEnum.values()){
            if (bizErrorCodeEnum.getCode().equals(code)){
                return bizErrorCodeEnum;
            }
        }
        return null;
    }
}
